import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sports_new/resources/colours.dart';
import 'package:sports_new/utils/utils.dart';

import 'base/qkd_text.dart';

class ItemBottomSheet extends StatelessWidget {
  final List<String> titles;
  final List<String> icons;
  final String? top;

  const ItemBottomSheet({
    super.key,
    this.top,
    required this.icons,
    required this.titles,
  });

  @override
  Widget build(BuildContext context) {
    return BottomSheet(
      enableDrag: false,
      clipBehavior: Clip.hardEdge,
      shape: const RoundedRectangleBorder(
          borderRadius: BorderRadius.only(
              topLeft: Radius.circular(10), topRight: Radius.circular(10))),
      onClosing: () {},
      builder: (context) {
        return Container(
          color: Colours.white,
          child: SafeArea(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisSize: MainAxisSize.min,
              children: [
                if (top != null)
                  Container(
                    height: 52,
                    child: Center(
                        child: QkdText(top!,
                            fontSize: 17, color: Colours.grey99
                        )),
                  ),
                SingleChildScrollView(
                  scrollDirection: Axis.horizontal,
                  child: Padding(
                    padding: const EdgeInsets.symmetric(horizontal: 12),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      children: List<Widget>.generate(
                        titles.length,
                        (index) => GestureDetector(
                          behavior: HitTestBehavior.opaque,
                          onTap: () {
                            Get.back(result: index);
                          },
                          child: Column(
                            mainAxisSize: MainAxisSize.min,
                            children: [
                              Image.asset(
                                Utils.getImgPath(icons[index]),
                                width: 50,height: 50,
                              ),
                              QkdText(
                                  titles[index],
                                  fontSize: 12,
                                  color: Colours.grey99
                              )
                            ],
                          ),
                        )
                     ).insertEvery(Container(width: 12)),
                    ).paddingSymmetric(vertical: 24),
                  ),
                ),
                Container(
                  height: 10,
                  width: double.infinity,
                  color: Colours.greyF7,
                ),
                GestureDetector(
                  behavior: HitTestBehavior.opaque,
                  onTap: () {
                    Get.back();
                  },
                  child: Container(
                    height: 52,
                    color: Colours.greyFD,
                    child: const Center(
                        child: QkdText('取消',
                            fontSize: 17, color: Colours.black292D32
                        )
                    ),
                  ),
                ),
              ],
            ),
          ),
        );
      },
    );
  }
}